#ifndef USERMANAGEMENT_H
#define USERMANAGEMENT_H

#include "./Common/sqlmanagement.h"
#include "Logger.hpp"
#include "./Common/config.h"

class UserManagementBase {
public:
    UserManagementBase(SQLManagement* sqlManager, const QString& tableName)
        : sql_m(sqlManager), tb(tableName) {}

    virtual bool Insert(const QJsonObject &userInfo);

    virtual bool Remove(const QString &userId);

    virtual bool Update(const QJsonObject &json_value);

    virtual QString GetIdByName(const QString &username);

    virtual QVariantMap GetInfo(const QString &userId);

    virtual bool isExist(const QString &userId);

protected:
    SQLManagement* sql_m;
    QString tb; // 表名
};

class PatientManagement : public UserManagementBase {
public:
    PatientManagement(SQLManagement* sqlManager) : UserManagementBase(sqlManager, "patient_tb") {}
};

class DoctorManagement : public UserManagementBase {
public:
    DoctorManagement(SQLManagement* sqlManager) : UserManagementBase(sqlManager, "doctor_tb") {}

    QVariantMap GetInfo(const QString &userId);
    bool Update(const QJsonObject &json_value) override;
    QVariantList GetDoctorsByProfession(const QString &profession);
    QVariantMap GetAllInfos();
};

#endif // USERMANAGEMENT_H
